package com.test.fundible.fundible_05_process.widget;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.test.fundible.R;
import com.test.fundible.fundible_05_process.Proces_fundiblesIn_fundiblefo_Data;
import com.test.fundible.fundible_05_process.DateP_fundibleickerDia_fundiblelog;
import com.test.fundible.fundible_00_http.OkHttpUtil;


public class DateS_fundibleelectVie_fundiblewManager extends BaseProc_fundibleessWid_fundiblegetManager {

    private TextView titl_fundibleeTv;
    private TextView inpu_fundibletTv;

    public DateS_fundibleelectVie_fundiblewManager(View view, Proces_fundiblesIn_fundiblefo_Data data, String page){
        super(view,data,page);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void in_fundibleit(){

        titl_fundibleeTv = mView.findViewById(R.id.vpds_tv_title);
        inpu_fundibletTv = mView.findViewById(R.id.vpds_tv_input);

        setTi_fundibletle(mDa_fundibleta.getTitle_fundible());
        inpu_fundibletTv.setHint(mDa_fundibleta.getHint_fundible());

        mView.findViewById(R.id.vpds_view_click).setOnClickListener(v -> {

            OkHttpUtil.getInstance_fundible().uploadEventPoint(TAG, mDa_fundibleta.getParamName_fundible().toUpperCase()+"_CLICK","");

            new DateP_fundibleickerDia_fundiblelog(
                    mView.getContext(),
                    mDa_fundibleta.getTitle_fundible(),
                    date -> {
                        inpu_fundibletTv.setText(date);
                        OkHttpUtil.getInstance_fundible().uploadEventPoint(TAG, mDa_fundibleta.getParamName_fundible().toUpperCase()+"_CLICK", getInp_fundibleut());
                    }
            ).show();
        });

    }

    @Override
    public boolean checkI_fundiblenput() {
        if (!mDa_fundibleta.isMustInput_fundible()) return true;
        return !TextUtils.isEmpty(inpu_fundibletTv.getText());
    }

    @Override
    public String getInp_fundibleut() {
        return inpu_fundibletTv.getText().toString();
    }

    public void setTi_fundibletle(String title){
        if (TextUtils.isEmpty(title)) titl_fundibleeTv.setVisibility(View.GONE);
        else {
            titl_fundibleeTv.setVisibility(View.VISIBLE);
            titl_fundibleeTv.setText(title);
        }
    }

}
